#!/bin/zsh -Ndefgku
#
# Scripts/clean
# mas
#
# Copyright © 2025 mas-cli. All rights reserved.
#
# Deletes the build folder & other generated files.
#

. "${0:A:h}/_setup_script"

print_notice '🗑​ Cleaning' "${@}"

zmodload zsh/zutil
zparseopts -D -A received_flag D P r x

if ! [[ -v 'received_flag[-P]' ]]; then
	swift package "${${received_flag[-D]+clean}:-reset}"
fi
if [[ -v 'received_flag[-r]' && -e Package.resolved ]]; then
	trash Package.resolved
fi
if [[ -v 'received_flag[-x]' && -d .swiftpm ]]; then
	trash .swiftpm
fi
